import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Layout from '@/layout/index.vue'
import ProcessManageRouter from './modules/progess_manage'
import UserCenterRouter from './modules/user_center'
import ProductInstrumentRouter from './modules/production_instrument'
import ErrorPageRouter from './modules/error'

Vue.use(VueRouter)

export const constantRoutes: RouteConfig[] = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/',
    component: Layout,
    name: 'layout',
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        name: 'Dashboard',
        meta: {
          title: '首页',
          icon: 'odometer',
          noCache: true,
          affix: true
        }
      },
      {
        path: 'dashboard/bigScreen',
        component: () => import('@/views/dashboard/subs/BigScreen.vue'),
        name: 'bigScreen',
        meta: { title: '数据大屏', hidden: true }
      },
      {
        path: 'dashboard/:meterid',
        component: () => import('@/views/progress_manage/progressOperation.vue'),
        name: 'dashboard',
        meta: { title: '工序操作', intercept: true, noCache: true, hidden: true }
      }
    ]
  }
]
export const asyncRoutes: RouteConfig[] = [
  ProcessManageRouter,
  ProductInstrumentRouter,
  UserCenterRouter,
  ...ErrorPageRouter
]

const createRouter = () =>
  new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes: constantRoutes
  })

const router = createRouter()

export default router
